package com.tgz;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.util.concurrent.TimeUnit;

@SpringBootApplication
@MapperScan("com.tgz.mapper")
public class SpringBootThemeleafMybatisPlusApplication implements CommandLineRunner {

	@Autowired
	private StringRedisTemplate stringRedisTemplate;

	public static void main(String[] args) {
		SpringApplication.run(SpringBootThemeleafMybatisPlusApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
	   try {
            stringRedisTemplate.opsForValue().set("TIME_OUT_KEY_123456789","123456789",5, TimeUnit.MINUTES);
            stringRedisTemplate.opsForValue().set("TIME_OUT_KEY_666666666","666666666",15, TimeUnit.MINUTES);
            stringRedisTemplate.opsForValue().set("TIME_OUT_KEY_888888888","888888888",30, TimeUnit.MINUTES);
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
}
